﻿using Model;
using System;
using System.Windows.Forms;


namespace ProjectStudent
{
    public partial class UserRegister : Form
    {
        public UserRegister()
        {
            InitializeComponent();
        }

        private void btnRegister_Click(object sender, EventArgs e)
        {
            string username = txtName.Text;
            string password = txtPassword.Text;
            if(string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password) )
            {
                MessageBox.Show("账号和密码不能为空");
                return;
            }
            //UserDao userDao = new UserDao();
            User user = new User() { Name =username,Password = password};
            if (textBox1.Text != txtPassword.Text)
            {
                MessageBox.Show("两次输入的密码不一样！");
                return;
            }
            //if (userDao.UserExits(username))
            //{
            //    MessageBox.Show("用户名已存在！");
            //    return;
            //}
            //else
            //{
            //    userDao.Register(user);
            //    MessageBox.Show("注册成功！");
            //    this.Close();
            //}
            
        }

        private void txtPassword_TextChanged(object sender, EventArgs e)
        {
           
                
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            //if(textBox1.Text != txtPassword.Text)
            //{
            //    MessageBox.Show("两次输入的密码不一样！");
            //    return;
            //}
        }

        private void Register_Load(object sender, EventArgs e)
        {
            //textBox1.Text = "请输入长度最大为8的内容";
            //textBox1.ForeColor = Color.Gray;
            //textBox1.Tag = "placeholder"; // 使用Tag标记当前是占位符状态
            
            //txtPassword.Text = "请输入长度最大为8的内容";
            //txtPassword.ForeColor = Color.Gray;
            //txtPassword.Tag = "placeholder"; // 使用Tag标记当前是占位符状态
        }

        // 处理获得焦点事件
        //private void textBox1_Enter(object sender, EventArgs e)
        //{
        //    if (textBox1.Tag != null && textBox1.Tag.ToString() == "placeholder")
        //    {
        //        textBox1.Text = "";
        //        textBox1.ForeColor = Color.Black;
        //        textBox1.Tag = null;
        //    }
        //}

        //// 处理失去焦点事件
        //private void textBox1_Leave(object sender, EventArgs e)
        //{
        //    if (string.IsNullOrWhiteSpace(textBox1.Text))
        //    {
        //        textBox1.Text = "请输入内容";
        //        textBox1.ForeColor = Color.Gray;
        //        textBox1.Tag = "placeholder";
        //    }
        //}
    }
}
